package com.achartengine.test;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.achartengine.test.activity.BubbleChartActivity;
import com.achartengine.test.activity.CurveActivity;
import com.achartengine.test.activity.HistogramActivity;
import com.achartengine.test.activity.HyperbolaActivity;
import com.achartengine.test.activity.PieChartActivity;
import com.achartengine.test.activity.ScatterDiagramActivity;
import com.achartengine.test.activity.SmoothCurveActivity;
import com.achartengine.test.activity.TimeFenActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8;
//
//    private CategorySeries mSeries;
//    private DefaultRenderer mRenderer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        setListener();
    }

    private void setListener() {
        btn1.setOnClickListener(this);
        btn2.setOnClickListener(this);
        btn3.setOnClickListener(this);
        btn4.setOnClickListener(this);
        btn5.setOnClickListener(this);
        btn6.setOnClickListener(this);
        btn7.setOnClickListener(this);
        btn8.setOnClickListener(this);
    }

    /**
     * 初始化View
     */
    private void initView() {
        btn1 = (Button) findViewById(R.id.button1);
        btn2 = (Button) findViewById(R.id.button2);
        btn3 = (Button) findViewById(R.id.button3);
        btn4 = (Button) findViewById(R.id.button4);
        btn5 = (Button) findViewById(R.id.button5);
        btn6 = (Button) findViewById(R.id.button6);
        btn7 = (Button) findViewById(R.id.button7);
        btn8 = (Button) findViewById(R.id.button8);
    }

    //    /**
//     * 程序异常退出，数据的保存
//     */
//    @Override
//    protected void onRestoreInstanceState(Bundle savedState) {
//        super.onRestoreInstanceState(savedState);
//        mSeries = (CategorySeries) savedState.getSerializable("current_series");
//        mRenderer = (DefaultRenderer) savedState.getSerializable("current_renderer");
//    }
//
//    @Override
//    protected void onSaveInstanceState(Bundle outState) {
//        super.onSaveInstanceState(outState);
//        outState.putSerializable("current_series", mSeries);
//        outState.putSerializable("current_renderer", mRenderer);
//    }
    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            //圆滑曲线图
            case R.id.button1:
                startActivity(new Intent(this, SmoothCurveActivity.class));
                break;
            //曲线图
            case R.id.button2:
                startActivity(new Intent(this, CurveActivity.class));
                break;
            //饼状图
            case R.id.button3:
                startActivity(new Intent(this, PieChartActivity.class));
                break;
            //柱状图
            case R.id.button4:
                startActivity(new Intent(this, HistogramActivity.class));
                break;
            //双曲线
            case R.id.button5:
                startActivity(new Intent(this, HyperbolaActivity.class));
                break;
            //散点图
            case R.id.button6:
                startActivity(new Intent(this, ScatterDiagramActivity.class));
                break;
            //泡沫图
            case R.id.button7:
                startActivity(new Intent(this, BubbleChartActivity.class));
                break;
            //时间分布图
            case R.id.button8:
                startActivity(new Intent(this, TimeFenActivity.class));
                break;

        }
    }
}
